                                   '-----------------------------------------------------------------------------------------
'name                     : m32.bas
'copyright                : (c) 1995-2005, MCS Electronics
'purpose                  : test file for Mega32
'micro                    : Mega32
'suited for demo          : yes
'commercial addon needed  : no
'-----------------------------------------------------------------------------------------

$regfile = "m16def.dat"

$crystal = 1000000
Config Portc = Output
Config Portd = Output
Portd = 0
Portc = &HF0

'This file is intended to test the Mega32
'The M32 has the JTAG enabled by default so you can not use
'pins PORTC.2-PORTC.5

'Use the following code to disable JTAG
'Mcusr = &H80
'Mcusr = &H80
'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.2 , Rs = Portd.0
'These settings are for the STK200 in PIN mode
'Connect only DB4 to DB7 of the LCD to the LCD connector of the STK D4-D7
'Connect the E-line of the LCD to A15 (PORTC.7) and NOT to the E line of the LCD connector
'Connect the RS, V0, GND and =5V of the LCD to the STK LCD connector

Rem with the config lcdpin statement you can override the compiler settings


Dim A As Byte
Config Lcd = 16 * 2                                         'configure lcd screen

Initlcd
'other options are 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
'When you dont include this option 16 * 2 is assumed
'16 * 1a is intended for 16 character displays with split addresses over 2 lines

'$LCD = address will turn LCD into 8-bit databus mode
'       use this with uP with external RAM and/or ROM
'       because it aint need the port pins !

Cls                                                         'clear the LCD display
Lcd "Hello world."                                          'display this at the top line
Waitms 1000
Portc = 0
End